# encoding:utf-8
from app.models.base import db
from datetime import datetime
from sqlalchemy import Integer, Boolean


class Employee(db.Model):
    """
    员工表
    """
    __tablename__ = 'employees'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    phone = db.Column(db.String(64), unique=True, index=True)
    email = db.Column("email", db.String(64), nullable=False, default="")
    gender = db.Column("gender", Integer, nullable=False)
    role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
    role = db.relationship("Role")
    is_locked = db.Column("is_locked", Boolean, default=False)
    create_time = db.Column(db.DateTime(), default=datetime.now)
    update_time = db.Column(db.DateTime(), default=datetime.now, onupdate=datetime.now)


class Role(db.Model):
    """角色表"""
    __tablename__ = 'roles'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)